Socket
Socket
Sign inDemoInstall

temp

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

temp

Temporary files and directories


Version published
Weekly downloads
8.2M
decreased by-3.44%
Maintainers
1
Weekly downloads
 
Created

What is temp?

The 'temp' npm package is designed to handle temporary files and directories in a Node.js environment. It provides utilities to create, manage, and clean up temporary files and directories, ensuring that they are properly removed when no longer needed.

What are temp's main functionalities?

Creating a Temporary File

This feature allows you to create a temporary file with a specified prefix. The callback provides information about the file, including its path and file descriptor.

const temp = require('temp');
temp.open('myprefix', function(err, info) {
  if (!err) {
    console.log('File: ', info.path);
    console.log('File descriptor: ', info.fd);
  }
});

Creating a Temporary Directory

This feature allows you to create a temporary directory with a specified prefix. The callback provides the path to the created directory.

const temp = require('temp');
temp.mkdir('myprefix', function(err, dirPath) {
  if (!err) {
    console.log('Directory: ', dirPath);
  }
});

Automatic Cleanup

This feature enables automatic cleanup of temporary files and directories when the process exits. By calling `temp.track()`, you ensure that all temporary files and directories are removed when they are no longer needed.

const temp = require('temp');
temp.track();
temp.open('myprefix', function(err, info) {
  if (!err) {
    console.log('File: ', info.path);
    console.log('File descriptor: ', info.fd);
  }
});

Other packages similar to temp

Keywords

FAQs

Package last updated on 30 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc